'''
Created on 19.02.2012

@author: myaut
'''

import sys
sys.path.append('../../lib')

from salsa.util.rpc import RPCInfo, RPCClient, RPCDispatcher

class SumServer:
    def function(self, a, b):
        return a + b

class MulServer:
    def function(self, a, b):
        return a * b

rpc_info = RPCInfo('cmd', 'data')
rpc_info.register(SumServer, ('function', 'sum'))
rpc_info.register(MulServer, ('function', 'mul'))

rpc_rq = RPCClient(rpc_info)

rpc_disp = RPCDispatcher(rpc_info)
rpc_disp.bind(SumServer(), MulServer())

sum_2_2 = rpc_rq.request('sum_function', 2, 2)
print rpc_disp.process(sum_2_2)

mul_2_3 = rpc_rq.request('mul_function', 2, 3)
print rpc_disp.process(mul_2_3)